public class PhoneNumbers
{
   /**
      Cleans a phone number.
      @param phoneNumber a phone number that should contain ten digits and possibly other characters
      @return the phone number in the form (###) ###-#### or the string "Error" if phoneNumber
      does not have ten digits
   */
   public String cleanNumber(String phoneNumber)
   {   
      // your work here
      int len = phoneNumber.length();
      int number = 0;
      String numbers = "(";
      for (int i = 0; i < len; i++)
      {
         char ch = phoneNumber.charAt(i);
         if (Character.isDigit(ch))
         {
            number++;
            numbers += ch;
            if(number == 3){
               numbers += ") ";
            }else if(number == 6){
               numbers += '-';
            }
         }
         
      }
      return number == 10 ? numbers : "Error";
   }   
}